<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
header("Cache-Control: no-cache, must-revalidate" ); 
header("Pragma: no-cache" );
header("Content-type: application/json");
require_once("class.markup_configs_helper.php");
$config_id=$_REQUEST["query"];


$arr=array();
if($config_id=='')
{
$arr=markup_configs_helper::get_all_markup();
}
else
{
    $arr=markup_configs_helper::get_markup_by_config($config_id);
}
$i=0;
$page=1;
$total=count($arr);
$rows=array();
//print_r($arr);
foreach($arr as $row)
{
 $rule=markup_configs_helper::get_markup_rule_by_rule_id($row["rule_id"]);   
 //echo $row["rule_id"];
 //print_r($row);
 $row1=array();
 $row2=array();
 $edit="<a href='#' onclick='edit_markup(&#39;".$row['rule_id']."&#39;)'><img src='css/money_add.png' align='absmiddle'  border='0'></a>";
  $delete="<a href='#' onclick='delete_markup(&#39;".$row['idmarkup_configs']."&#39;,&#39;".$config_id."&#39;)'><img src='css/money_delete.png' align='absmiddle'  border='0'></a>";
 $row1["cell"]=array($row["start_date"],$row["end_date"],$row["fare_type"],$row["airline_code"],$row["trip_type"],$row["ptc"],$row["cabin_class"],$row["sid"],$row["price_range"],$row["time_search"],$row["flight_type"],$rule["markup_type"],$rule["markup_value_type"],$rule["markup_apply_on"],$rule["value"],$edit,$delete);
 $row1["id"]=$i;
 $i++;
 $rows[]=$row1;
 
 
}
echo json_encode(array("page"=>$page,"rows"=>$rows,"total"=>$total));
?>